package com.db;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public class Transport {
    public String request(String request) throws TransportException {
        try(Socket socket = new Socket("127.0.0.1", 6666)) {
            DataOutputStream out = new DataOutputStream(socket.getOutputStream());
            DataInputStream in = new DataInputStream(socket.getInputStream());

            out.writeUTF(request);
            return in.readUTF();

        } catch(IOException e) {
            throw new TransportException(e);
        }
    }
}
